APP = sqlim
VER = 1.32
BNAME = $(APP)-$(VER)
TARBZ = $(BNAME).tar.gz

TPL =                  \
src/tpl/sqlim.css      \
src/tpl/footer.tpl     \
src/tpl/header.tpl     \
src/tpl/period.tpl     \
src/tpl/ulist.tpl      \
src/tpl/user.tpl       \
src/tpl/users.tpl      \
src/tpl/detail.tpl

CGI =                  \
src/cgi-bin/detail.cgi \
src/cgi-bin/index.cgi 

OTHER =                \
src/db.sql             \
src/history.txt        \
src/readme.txt

CMD =                  \
src/pass_basic         \
src/pass_basic_del     \
src/sq2db.pl           \
src/sqlim_acl.pl       \
src/sqlim_sum.pl       \
src/util.pl            \
src/config.pl   

SRC = $(TPL) $(CGI) $(CMD) $(OTHER)

all: $(BNAME).rpm

$(TARBZ): $(SRC)
	@chmod +x $(CGI) $(CMD)
	@mkdir $(BNAME)
	@cp $(OTHER) $(CMD) $(BNAME)/
	@mkdir $(BNAME)/tpl
	@cp $(TPL) $(BNAME)/tpl/
	@mkdir $(BNAME)/cgi-bin
	@cp $(CGI) $(BNAME)/cgi-bin/
	@tar -czf $(TARBZ) $(BNAME)/
	@rm -drf ./$(BNAME)

clean:
	-@rm $(TARBZ)
	-@rm $(BNAME).rpm

$(BNAME).rpm: $(TARBZ) sqlim.spec
	cp $(TARBZ) /usr/src/redhat/SOURCES/
	rpmbuild -ba --quiet $(APP).spec

